package com.sky.mapper;

import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {
/**跟新数据*/
    void insertShopCart(ShoppingCart shoppingCart);

    /**跟新餐品数量*/
    @Update("update shopping_cart set number = #{number} where dish_id = #{dishId}")
    void updateNumber(Integer number,Long dishId);

    /**根据菜品id查询购物车数据*/
    ShoppingCart selectCartByDishId(Long dishId, Long userId, String dishFlavor);

    /**根据套餐id查询购物车数据*/
    ShoppingCart selectCartBySetmealId(Long setmealId, Long userId, String dishFlavor);

    /**查询购物车信息*/
    @Select("select * from shopping_cart where user_id =#{userId}")
    List<ShoppingCart> selectAll(Long userId);

    /**跟新餐品数量*/
    @Update("update shopping_cart set number = #{number} where setmeal_id = #{setmealId}")
    void updatesetmealNumber(Integer number, Long setmealId);

    /**删除一个商品*/
    void deleteAShop(ShoppingCartDTO shoppingCartDTO);

    /**清空购物车*/
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteAll(Long userId);
/**无条件查询购物车所有*/
    @Select("select * from shopping_cart")
    List<ShoppingCart> selectAllNoCondtion();
}
